home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / keyservh / mainform.frm < prev    next >
Text File  |  1999-08-20  |  5KB  |  181 lines

  1. VERSION 5.00
  2. Begin VB.Form MainForm 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Service Test Harness"
  5.    ClientHeight    =   1545
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   4395
  9.    Icon            =   "MainForm.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   1545
  13.    ScaleWidth      =   4395
  14.    StartUpPosition =   1  'CenterOwner
  15.    Begin VB.CommandButton Shutdown 
  16.       Caption         =   "Shutdown"
  17.       Enabled         =   0   'False
  18.       Height          =   375
  19.       Left            =   3360
  20.       TabIndex        =   6
  21.       Top             =   1080
  22.       Width           =   975
  23.    End
  24.    Begin VB.CommandButton Control 
  25.       Caption         =   "Control"
  26.       Enabled         =   0   'False
  27.       Height          =   375
  28.       Left            =   2280
  29.       TabIndex        =   5
  30.       Top             =   1080
  31.       Width           =   975
  32.    End
  33.    Begin VB.CommandButton PauseContinue 
  34.       Caption         =   "Pause"
  35.       Enabled         =   0   'False
  36.       Height          =   375
  37.       Left            =   1200
  38.       TabIndex        =   4
  39.       Top             =   1080
  40.       Width           =   975
  41.    End
  42.    Begin VB.CommandButton StartStop 
  43.       Caption         =   "Start"
  44.       Enabled         =   0   'False
  45.       Height          =   375
  46.       Left            =   120
  47.       TabIndex        =   3
  48.       Top             =   1080
  49.       Width           =   975
  50.    End
  51.    Begin VB.TextBox ProgId 
  52.       Height          =   285
  53.       Left            =   1440
  54.       TabIndex        =   2
  55.       Top             =   600
  56.       Width           =   2895
  57.    End
  58.    Begin VB.Label Label2 
  59.       Caption         =   "Specify the Prog ID of the ActiveX class you want to test."
  60.       Height          =   375
  61.       Left            =   120
  62.       TabIndex        =   0
  63.       Top             =   120
  64.       Width           =   4095
  65.    End
  66.    Begin VB.Label Label1 
  67.       Caption         =   "Service Prog ID:"
  68.       Height          =   255
  69.       Left            =   120
  70.       TabIndex        =   1
  71.       Top             =   600
  72.       Width           =   1215
  73.    End
  74. End
  75. Attribute VB_Name = "MainForm"
  76. Attribute VB_GlobalNameSpace = False
  77. Attribute VB_Creatable = False
  78. Attribute VB_PredeclaredId = True
  79. Attribute VB_Exposed = False
  80. '****************************************************************************************************
  81. '   Copyright (c) Key Technology Pty Ltd 1999, All Rights Reserved.
  82. '   Web site: http://www.keytech.com.au  Email: info@keytech.com.au
  83. '****************************************************************************************************
  84.  
  85. Option Explicit
  86.  
  87. '
  88. ' The service test harness may be used to test ActiveX controls that are to be
  89. ' hosted by the Service Host executable.
  90. '
  91.  
  92. Private ServiceObject As IService
  93.  
  94. Private Sub ProgId_Change()
  95.     If StartStop.Caption = "Start" Then
  96.         StartStop.Enabled = (Len(ProgId) <> 0)
  97.     End If
  98. End Sub
  99.  
  100. Private Sub StartStop_Click()
  101.     On Error Resume Next
  102.     
  103.     If StartStop.Caption = "Start" Then
  104.         Set ServiceObject = CreateObject(ProgId)
  105.         
  106.         If Err Then
  107.             MsgBox "Failed to create service object. " & vbNewLine & _
  108.                    "Check that the ActiveX DLL is properly installed."
  109.             Exit Sub
  110.         End If
  111.  
  112.         ServiceObject.OnStart
  113.         
  114.         If Err Then
  115.             MsgBox "OnStart failed - " & Err.Description
  116.         End If
  117.         
  118.         PauseContinue.Enabled = ServiceObject.Pausable
  119.         Control.Enabled = True
  120.         Shutdown.Enabled = True
  121.         
  122.         StartStop.Caption = "Stop"
  123.     Else
  124.         ServiceObject.OnStop
  125.         
  126.         If Err Then
  127.             MsgBox "OnStop failed - " & Err.Description
  128.         End If
  129.         
  130.         PauseContinue.Enabled = False
  131.         Control.Enabled = False
  132.         Shutdown.Enabled = False
  133.         
  134.         StartStop.Caption = "Start"
  135.     End If
  136. End Sub
  137.  
  138. Private Sub PauseContinue_Click()
  139.     On Error Resume Next
  140.     
  141.     If PauseContinue.Caption = "Pause" Then
  142.         ServiceObject.OnPause
  143.         
  144.         If Err Then
  145.             MsgBox "OnPause failed - " & Err.Description
  146.         End If
  147.         
  148.         PauseContinue.Caption = "Continue"
  149.     Else
  150.         ServiceObject.OnContinue
  151.         
  152.         If Err Then
  153.             MsgBox "OnContinue failed - " & Err.Description
  154.         End If
  155.         
  156.         PauseContinue.Caption = "Pause"
  157.     End If
  158. End Sub
  159.  
  160. Private Sub Control_Click()
  161.     On Error Resume Next
  162.     
  163.     ' OpCode must be within the range 128 to 255 inclusive
  164.     ServiceObject.OnControl 128
  165.     
  166.     If Err Then
  167.         MsgBox "OnShutdown failed - " & Err.Description
  168.     End If
  169. End Sub
  170.  
  171. Private Sub Shutdown_Click()
  172.     On Error Resume Next
  173.     
  174.     ServiceObject.OnShutdown
  175.     
  176.     If Err Then
  177.         MsgBox "OnShutdown failed - " & Err.Description
  178.     End If
  179. End Sub
  180.  
  181.